//
//  BGOwnAuctionCell.m
//  bigMall
//
//  Created by LTOVE on 16/9/18.
//  Copyright © 2016年 thinklev. All rights reserved.
//

#import "BGOwnAuctionCell.h"
#import "BGOwnAuctionModel.h"
static NSString *const reuseIdentify = @"cell";
@implementation BGOwnAuctionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    // Configure the view for the selected state
}

- (void)setModel:(BGOwnAuctionModelRes *)model
{
    _model = model;
    [self setUpAllSubviewsWithModel:model];
}

- (void)setUpAllSubviewsWithModel:(BGOwnAuctionModelRes *)model
{
    //清空cell
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    //内容视图
    UIView *contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenW, model.cellHeigh)];
    
    //标题
    UILabel *titleLabel = [self labelWithTitle:model.title textColor:textBlackColor font:Font34];
    UILabel *timeLabel = [self labelWithTitle:model.add_time textColor:textGrayColor font:Font28];
    UILabel *ChuJia = [self labelWithTitle:@"出价" textColor:textBlackColor font:Font34];
    UILabel *numLabel = [self labelWithTitle:model.total_amount textColor:read_ font:Font34];
    UILabel *unit = [self labelWithTitle:@"元" textColor:textBlackColor font:Font34];
    titleLabel.x = BGMaginLeft;
    titleLabel.y = BGMaginTop;
    timeLabel.x = contentView.width - BGMaginLeft - timeLabel.width;
    timeLabel.centerY = titleLabel.centerY;
    ChuJia.y = numLabel.y = unit.y = CGRectGetMaxY(titleLabel.frame) + 5;
    ChuJia.x = BGMaginLeft;
    numLabel.x = CGRectGetMaxX(ChuJia.frame);
    unit.x = CGRectGetMaxX(numLabel.frame);
    [contentView addSubview:titleLabel];
    [contentView addSubview:timeLabel];
    [contentView addSubview:ChuJia];
    [contentView addSubview:numLabel];
    [contentView addSubview:unit];
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(BGMaginLeft, CGRectGetMaxY(ChuJia.frame) + 5, screenW - 2 * BGMaginLeft, 1)];
    lineView.backgroundColor = lightGray_;
    [contentView addSubview:lineView];
//    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, contentView.height - 10, screenW, 10)];
    
    [self.contentView addSubview:contentView];
    //时间
    
    //出价
    
}
- (UILabel *)labelWithTitle:(NSString *)title textColor:(UIColor *)textColor font:(UIFont *)font
{
    UILabel *label = [UILabel new];
    label.text = title;
    label.font = font;
    label.textColor = textColor;
    [label sizeToFit];
    return label;
}
+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    BGOwnAuctionCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentify];
    if (!cell) {
        cell = [[self alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentify];
    }
    return cell;
}

@end
